<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>修改密码</title>
		<link rel="stylesheet" href="../../css/aui.css" />
		<link rel="stylesheet" href="../../css/my/reset_password.css">
	</head>
<body style="cursor: pointer;">
	<ul class="aui-list aui-form-list from_padded aui-padded-t-15" style="border:none;">
		<form id="myform" data-parsley-trigger="blur" role="form" action="#" method="POST">
			<li class="aui-list-item ">
				<label style="width:50%;line-height:2.2rem;">原密码：</label>
				<input type="password" style="font-size:1rem;" name="oldPassword" placeholder="请输入原密码(填写6到12位密码)">
			</li>

			<li class="aui-list-item ">
				<label style="width:50%;line-height:2.2rem;">新密码：</label>
				<input type="password" name="password" placeholder="请输入新密码(填写6到12位密码)">
			</li>

			<li class="aui-list-item col_center">
				<label style="width:50%;line-height:2.2rem;">确认新密码：</label>
				<input type="password" name="rePassword" placeholder="请输入确认密码(填写6到12位密码)">
			</li>

			<div class="aui-btn aui-btn-block btn_padded reset" style="background:#3cb0d6;" onclick="password_submit()">确定</div>
		</form>
	</ul>
</body>
</html>
<script type="text/javascript" src="../../script/aui/api.js"></script>
<script type="text/javascript" src="../../script/extend/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/aui/aui-toast.js" ></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>

<script type="text/javascript">
    apiready = function() {
        api.parseTapmode();

    };

	// TODO: 修改密码
	function password_submit(){
    oldPassword  = $('input[name=oldPassword]').val();
		password     = $('input[name=password]').val();
		rePassword   = $('input[name=rePassword]').val();

		if (!isDefine(oldPassword)) {
			$toast('请输入原始密码');
			return;
		}

		if (!isDefine(password)) {
				$toast('请输入新密码');
				return;
		}

		if (!isDefine(rePassword)) {
			$toast('请再次输入新密码');
			return;
		}

		if(!checkPwd(password)){
			return;
		}

		if (!recheckpayPwd(password,rePassword)) {
			$toast('两次密码输入不一致');
			return;
		}

        var data = {oldPassword: oldPassword, password:password, rePassword:rePassword};
        ajax({url:Config.common.modifyPassword,data:data },function(ret){
            if (ret.code == 1) {
                alert('密码修改成功,请重新登录!');
                $api.clearStorage();
								api.closeWin({});
								api.closeWin({
                    name: 'main'
                });
                openWin('login', '../login/login.html')
            } else {
                alert(ret.msg);
            }
        })
	}
</script>
